{{>licenseInfo}}
{{#models}}{{#model}}defmodule {{moduleName}}.Model.{{classname}} do
  @moduledoc """
  {{&description}}
  """

  @derive [Poison.Encoder]
  defstruct [
    {{#vars}}:"{{&baseName}}"{{^-last}},
    {{/-last}}{{/vars}}
  ]

  @type t :: %__MODULE__{
    {{#vars}}:"{{&baseName}}" => {{{datatype}}}{{#isNullable}} | nil{{/isNullable}}{{^isNullable}}{{^required}} | nil{{/required}}{{/isNullable}}{{^-last}},
    {{/-last}}{{/vars}}
  }
end

defimpl Poison.Decoder, for: {{&moduleName}}.Model.{{&classname}} do
{{#hasComplexVars}}
  import {{&moduleName}}.Deserializer
  def decode(value, options) do
    value
    {{#vars}}
    {{^isPrimitiveType}}
    {{#baseType}}|> deserialize(:"{{&baseName}}", {{#isArray}}:list, {{&moduleName}}.Model.{{{items.baseType}}}{{/isArray}}{{#isMap}}:map, {{&moduleName}}.Model.{{{items.baseType}}}{{/isMap}}{{#isDate}}:date, nil{{/isDate}}{{#isDateTime}}:date, nil{{/isDateTime}}{{^isDate}}{{^isDateTime}}{{^isMap}}{{^isArray}}:struct, {{moduleName}}.Model.{{baseType}}{{/isArray}}{{/isMap}}{{/isDateTime}}{{/isDate}}, options)
    {{/baseType}}
    {{/isPrimitiveType}}
    {{/vars}}
{{/hasComplexVars}}
{{^hasComplexVars}}
  def decode(value, _options) do
    value
{{/hasComplexVars}}
  end
end
{{/model}}{{/models}}
